package recordsDatabase;

import java.io.Serializable;
import java.util.ArrayList;

public class Category implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 676873179253353942L;
	private String category;
	private ArrayList<CategoryDetails> entriesList;
	
	public Category(String value){
		this.category=value;
		entriesList = new ArrayList<CategoryDetails>(); 
	}
	
	public ArrayList<CategoryDetails> getEntriesList(){
		return entriesList;
	}
	
	public void addEntry(CategoryDetails cd){
		entriesList.add(cd);
	}
	
	public String getCategoryName(){
		return this.category;
	}
	
	public boolean entryExistsInList(String value){
		for (CategoryDetails cd:entriesList){
			if (cd.getField().equals(value)) return true;
		}
		return false;
	}
	
	public CategoryDetails getCategoyDetails(String value){
		CategoryDetails tmp=null;
		for (CategoryDetails cd:entriesList){
			if (cd.getField().equalsIgnoreCase(value)) return cd;
		}
		return tmp;
	}
	
	
}
